#include "Anthill.h"
#include <iostream>
#include "ItemCreator.h"
#include "Environment.h"
#include "FoodCountException.h"
#include "AntColony.h"

CAnthill::CAnthill(int in_uiFoodCount) : m_uiFoodCount(in_uiFoodCount)
{
	
}


CAnthill::~CAnthill(void)
{
}

void CAnthill::act(int id)
{
	
	if ( m_uiFoodCount < g_uiFoodCostForAnt)
	{
		CEnvironment* pEnvironment=CEnvironment::Instance();
		if(!pEnvironment->AntAlive())
		{
			throw CFoodCountException(m_uiFoodCount);
		}
	
	}


	if (m_uiFoodCount>=g_uiFoodCostForAnt)
	{
		CItemCreator* pItemCreator=CItemCreator::Instance();
		CEnvironment* pEnvironment=CEnvironment::Instance();
		CArea* pArea=GetPosition();
		pEnvironment->InsertItem(pArea,pItemCreator->CreateAnt());
		m_uiFoodCount-=g_uiFoodCostForAnt;
	}

	//std::cout << "Anthill acting" << std::endl;

}
void CAnthill::AddFood(const int in_iFood)
{
	m_uiFoodCount+=in_iFood;
}

